package com.huizhonglm.diap.presenters.wallet;

import com.alibaba.fastjson.JSON;
import com.bruce.common.utils.EmptyUtil;
import com.huizhonglm.diap.api.API;
import com.huizhonglm.diap.api.CommonResponse;
import com.huizhonglm.diap.api.HttpCallback;
import com.huizhonglm.diap.api.Status;
import com.huizhonglm.diap.api.model.user.MyRecommentUserParams;
import com.huizhonglm.diap.presenters.BasePresenter;
import com.huizhonglm.diap.ui.wallet.iView.RcmUserIView;

/**
 * 描述当前类的作用
 * 处理我的积分明细
 */
public class RcmUserPresenter extends BasePresenter {

    private RcmUserIView iView;


    public RcmUserPresenter(RcmUserIView iView) {
        this.iView = iView;
    }

    public void loadData(String userId, String phoneNo){
        MyRecommentUserParams params = new MyRecommentUserParams();
        params.userId = userId;
        params.phoneNo = phoneNo;
        API.http().post("phoneNoBindRemder", params, new HttpCallback() {
            @Override
            public void onSuccess(String result) {
                if (!EmptyUtil.isEmpty(result)) {
                    CommonResponse res = JSON.parseObject(result, CommonResponse.class);
                    if (res != null && Status.SUCCESS.equals(res.getStatus())) {
                        iView.onBindUserSuccess();
                    } else {
                        iView.onBindUserFailure();
                    }
                } else {
                    iView.onBindUserFailure();
                }
            }

            @Override
            public void onFailure(Throwable ex) {
                iView.onBindUserFailure();
            }
        });
    }

}
